package com.probox.modules.controller.centre;

import com.probox.common.core.enums.CentreOrderType;
import com.probox.common.core.web.controller.BaseController;
import com.probox.common.core.web.domain.AjaxResult;
import com.probox.common.entity.service.centre.IOrderInfoService;
import com.probox.common.entity.vo.centre.WarningDataVo;
import com.probox.common.entity.vo.centre.map.ProductAxisMap;
import com.probox.common.entity.vo.centre.order.OrderDataVo;
import com.probox.common.entity.vo.centre.order.OrderQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单子Controller
 *
 * @author hds
 * @date 2021-06-24
 */
@Api(value = "数据中心模块",tags = {"订单数据接口"})
@RestController
@RequestMapping("/centre-data/count/order")
public class CentreOrderInfoController extends BaseController {

    @Autowired()
    private IOrderInfoService orderInfoService;


    /**
     *查询商品预警 待发货 待售后 投诉处理
     *
     * @return
     */
    @ApiOperation(value = "待发货 待售后 投诉处理")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = WarningDataVo.class)})
    @GetMapping("getProductWarning")
    public AjaxResult getProductWarning(OrderQueryVo orderQueryVo) throws Exception {
        return AjaxResult.success( orderInfoService.getWarningData(orderQueryVo));
    }


    /**
     *查询查询总单数、总金额、交易单数、交易金额
     *
     * @return
     */
    @ApiOperation(value = "查询总单数、总金额、交易单数、交易金额")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderDataVo.class)})
    @GetMapping("getOrderCollect")
    public AjaxResult getOrderCollect(OrderQueryVo orderQueryVo) throws Exception {
        return AjaxResult.success( orderInfoService.getOrderCollect(orderQueryVo));
    }


    /**
     * 取消单数  取消金额 未支付单数 未支付金额
     *
     * @return
     */
    @ApiOperation(value = "取消单数、取消金额、未支付单数、未支付金额")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderDataVo.class)})
    @GetMapping("getOrderUnfinishedCollect")
    public AjaxResult getOrderUnfinishedCollect(OrderQueryVo orderQueryVo){
        return AjaxResult.success( orderInfoService.getOrderUnfinishedCollect(orderQueryVo));
    }


    /**
     * 售后单数  投诉单数 买家数量 成交卖家数 取消卖家数
     *
     * @return
     */
    @ApiOperation(value = "售后单数、投诉单数、买家数量、成交卖家数、取消卖家数")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderDataVo.class)})
    @GetMapping("getOrderAfterSaleCollect")
    public AjaxResult getOrderAfterSaleCollect(OrderQueryVo orderQueryVo){
        return AjaxResult.success( orderInfoService.getOrderAfterSaleCollect(orderQueryVo));
    }


    /**
     * 查询当天支付金额 支付买家数
     *
     * @return
     */
    @ApiOperation(value = "支付金额 支付买家数")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderDataVo.class)})
    @GetMapping("getOrderTodayCollect")
    public AjaxResult getOrderTodayCollect(OrderQueryVo orderQueryVo){
        return AjaxResult.success( orderInfoService.getOrderTodayCollect(orderQueryVo));
    }


    /**
     * 查询当天 、 昨日24小时内支付金额
     *
     * @return
     */
    @ApiOperation(value = "查询当天支付、昨天成交金额图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getOrderTodayMap")
    public AjaxResult getOrderTodayMap(OrderQueryVo orderQueryVo){
        return AjaxResult.success( orderInfoService.getOrderTodayMap(orderQueryVo));
    }


    /**
     *
     * @return
     */
    @ApiOperation(value = "总金额 总单数 成交金额 成交单数 与前相同天数进行对比数据")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderDataVo.class)})
    @GetMapping("getOrderMoneyCollect")
    public AjaxResult getOrderMoneyCollect(OrderQueryVo orderQueryVo) throws Exception {
        return AjaxResult.success(orderInfoService.getOrderMoneyCollect(orderQueryVo));
    }

    /**
     * 查询近一月总金额图
     * @return
     */
    @ApiOperation(value = "查询订单折线图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getOrderMap")
    public AjaxResult getOrderMap(OrderQueryVo orderQueryVo){
        String type = orderQueryVo.getType();
       if (CentreOrderType.makeOrderMoneyTotal.getKey().equals(type)){
           return AjaxResult.success(orderInfoService.getMakeOrderMoneyTotalMap(orderQueryVo));
        }else if (CentreOrderType.makeOrderTotal.getKey().equals(type)){
           return AjaxResult.success(orderInfoService.getMakeOrderTotalMap(orderQueryVo));
        }else if (CentreOrderType.orderTotal.getKey().equals(type)){
            return AjaxResult.success(orderInfoService.getOrderTotalMap(orderQueryVo));
        }else if (CentreOrderType.orderMoneyTotal.getKey().equals(type)) {
           return AjaxResult.success(orderInfoService.getOrderMoneyTotalMap(orderQueryVo));
        }else if (CentreOrderType.cancelOrderDate.getKey().equals(type)) {
           return AjaxResult.success(orderInfoService.getCancelMoney(orderQueryVo));
        }
        return null;
    }


    /**
     * 查询近一月总金额图
     * @return
     */
    @ApiOperation(value = "查询近一月总金额图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getOrderMoneyTotalMap")
    public AjaxResult getOrderMoneyTotalMap(OrderQueryVo orderQueryVo){
        return AjaxResult.success(orderInfoService.getOrderMoneyTotalMap(orderQueryVo));
    }


    /**
     * 查询近一月总订单数图
     * @return
     */
    @ApiOperation(value = "查询近一月总订单数图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getOrderTotalMap")
    public AjaxResult getOrderTotalMap(OrderQueryVo orderQueryVo){
        return AjaxResult.success(orderInfoService.getOrderTotalMap(orderQueryVo));
    }


    /**
     * 查询近一月成交金额图
     * @return
     */
    @ApiOperation(value = "查询近一月成交金额图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getMakeOrderMoneyTotalMap")
    public AjaxResult getMakeOrderMoneyTotalMap(OrderQueryVo orderQueryVo){
        return AjaxResult.success(orderInfoService.getMakeOrderMoneyTotalMap(orderQueryVo));
    }


    /**
     * 查询成交单数
     * @return
     */
    @ApiOperation(value = "查询成交单数")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getMakeOrderTotalMap")
    public AjaxResult getMakeOrderTotalMap(OrderQueryVo orderQueryVo){

        return AjaxResult.success(orderInfoService.getMakeOrderTotalMap(orderQueryVo));
}

    /**
     * 查询当天、昨天订单数据汇总  下单未付款金额(元) 下单未付款订单数 取消金额(元) 取消单数(元)
     * @return
     */
    public AjaxResult getTodayNonPayment(OrderQueryVo orderQueryVo){
        return null;
    }

    /**
     * 查询近三十天取消金额
     * @return
     */
    @ApiOperation(value = "查询近一月取消金额图")
    @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductAxisMap.class)})
    @GetMapping("getCancelMoney")
    public AjaxResult getCancelMoney(OrderQueryVo orderQueryVo){
        return AjaxResult.success(orderInfoService.getCancelMoney(orderQueryVo));
    }
}
